|
|
|
|
|
|
|
Figure 2.3
Example program Lines compares the speeds of Visual Basic's Line
statement and the Polyline API function. |
|
|
|
|
|
|
|
|
MoveToEx and LineTo Functions |
|
|
|
|
|
|
|
|
The MoveToEx function sets the current X and Y positions for future drawing using LineTo. It returns the coordinates of the previous current position in a POINTAPI parameter. Usually a program does not need these coordinates. |
|
|
|
|
|
|
|
|
LineTo draws a line from the current position to the position specified. This function returns a non-zero value if it is successful and zero if there is an error. |
|
|
|
|
|
|
|
|
MoveToEx and LineTo do not change the values of Visual Basic's CurrentX and CurrentY properties. Note, however, that the Visual Basic Line method resets the current position used by the LineTo function. To prevent unnecessary confusion, you should avoid mixing the MoveToEx and LineTo functions with Visual Basic's Line method. |
|
|
|
|
|
|
|
|
The following code shows declarations for the MoveToEx and LineTo functions. The final argument to the MoveToEx function is normally the address of a POINTAPI data structure. It is declared here as type Any, so the program can use the value vbNullString for that argument. The MoveToEx function understands that it should not return the current drawing location when this parameter is null. |
|
|
|
 |
|
|
|
|
Private Declare Function MoveToEx Lib "gdi32" _
Alias "MoveToEx" (ByVal hdc As Long, _
ByVal x As Long, ByVal y As Long, lpPoint As Any) _
As Long
Private Declare Function LineTo Lib "gdi32" _
Alias "LineTo" (ByVal hdc As Long, _
ByVal x As Long, ByVal y As Long) As Long |
|
|
|
|
|